package com.sf.fy.uav.order.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sf.fy.uav.common.request.order.OrderExtraRequest;
import com.sf.fy.uav.common.utils.BeanUtil;
import com.sf.fy.uav.order.entity.OrderExtra;
import com.sf.fy.uav.order.mapper.OrderExtraMapper;
import com.sf.fy.uav.order.service.IOrderExtraService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author LTQ
 * @since 2023-06-19
 */
@Service
public class OrderExtraServiceImpl extends ServiceImpl<OrderExtraMapper, OrderExtra> implements IOrderExtraService {
    @Autowired
    private OrderExtraMapper orderExtraMapper;

    @Override
    public void add(OrderExtraRequest orderExtraRequest) {
        OrderExtra orderExtra = BeanUtil.copyProperties(orderExtraRequest, OrderExtra.class);
        orderExtraMapper.insert(orderExtra);
    }

    @Override
    public OrderExtra getByOrderId(String orderId) {
        QueryWrapper<OrderExtra> orderExtraQueryWrapper = new QueryWrapper<>();
        orderExtraQueryWrapper.eq("order_id", orderId);
        OrderExtra orderExtra = orderExtraMapper.selectOne(orderExtraQueryWrapper);
        return orderExtra;
    }

}
